import http from '@/utils/http'

const BASE_URL = '/shop/sell-record'

export interface SellRecordResp {
  id: string
  sellerId: string
  enrollmentId: string
  studentId: string
  classId: string
  campusId: string
  performance: number
  businessType: string
  businessId: string
  businessTime: string
  valid: boolean
  remark: string
  sellerName: string
  studentName: string
  className: string
  campusName: string
}

export interface FinAccountDetailResp {
  id: string
  name: string
  account: string
  remark: string
  status: number
}

export interface SellRecordQuery {
  term?: string
  campusId?: string
  subject?: string
  classYear?: string
  grade?: string[]
  startDate?: string
  endDate?: string
  sellerId?: string[]
  valid?: boolean
}

export interface SellStatsResp {
  sellerId: string
  sellerName: string
  subject: string
  performance: number
}

export interface SellRecordUpdateReq {
  remark: string
  valid: boolean
}

/** @desc 查询销售顾问业绩列表 */
export function getPage(query: SellRecordQuery & PageQuery) {
  return http.get<SellRecordResp[]>(`${BASE_URL}/page`, query)
}

/** @desc 查询销售顾问业绩列表 */
export function getList(query: SellRecordQuery) {
  return http.get<SellRecordResp[]>(`${BASE_URL}/list`, query)
}

/** @desc 查询销售顾问业绩统计 */
export function getStats(query: SellRecordQuery) {
  return http.get<SellStatsResp[]>(`${BASE_URL}/statsList`, query)
}

/** @desc 修改销售顾问业绩 */
export function update(data: any, sellRecordId: string) {
  return http.post(`${BASE_URL}/update/${sellRecordId}`, data)
}
